//
//  HWBindPhoneView.m
//  SNS_Login-register
//

#import "HWExchangeView.h"
#import "WHToast.h"
#import "HWGameMgr.h"
#import "HWConstant.h"



@interface HWExchangeView ()

@property (weak, nonatomic) IBOutlet UILabel *title;
@property (weak, nonatomic) IBOutlet UILabel *tips;

@property (weak, nonatomic) IBOutlet UITextField *userAccountTextField;
@property (weak, nonatomic) IBOutlet UITextField *userDiamondTextField;
@property (weak, nonatomic) IBOutlet UITextField *goodsNameTextField;
@property (weak, nonatomic) IBOutlet UITextField *goodsPriceTextField;
@property (weak, nonatomic) IBOutlet UIButton *exchangeBtn;


@end

@implementation HWExchangeView

+ (instancetype)HWExchangeView{
    NSString  *clsName = NSStringFromClass([self class]);
    UINib * nib = [UINib nibWithNibName:clsName bundle:nil];
    HWExchangeView * obj = [nib instantiateWithOwner:nil options:nil].firstObject;
    [obj initGameView];
    return obj;
    
}

-(void)updateData:(NSDictionary*)dic{
    self.userAccountTextField.text = [dic objectForKey:@"username"];
    self.userDiamondTextField.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"diamondNum"]];
    self.goodsNameTextField.text = [dic objectForKey:@"name"];
    self.goodsPriceTextField.text = [NSString stringWithFormat:@"%@",[dic objectForKey:@"price"]];
    self.tips.text = [dic objectForKey:@"tips"];
}

-(void)initGameView{
    // 创建一个富文本对象
    NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
    // 设置富文本对象的颜色
    attributes[NSForegroundColorAttributeName] = [UIColor grayColor];
//    _userAccountTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"请输入账号" attributes:attributes];
}

#pragma mark - 兑换
- (IBAction)exchangeBtnClick:(id)sender {
    [[HWGameMgr shared] callToJsWithMethed:kSDKShowExchangeCallBack andDic:
         @{
            @"username":self.userAccountTextField.text,
            @"diamondNum":self.userDiamondTextField.text,
            @"name":self.goodsNameTextField.text,
            @"price":self.goodsPriceTextField.text
            
        }
    ];
}


- (void)switchToLogin{
//    _title.text = @"登录";
//    _tips.text = @"没有账号？点此";
//    [_switchBtn setTitle:@"注册" forState:UIControlStateNormal];
//    [_switchBtn setTitle:@"注册" forState:UIControlStateSelected];
//    [_regLoginBtn setTitle:@"登录" forState:UIControlStateNormal];
//    [_regLoginBtn setTitle:@"登录" forState:UIControlStateSelected];
}



#pragma mark - 点击事件
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        //収键盘
    [self.userAccountTextField resignFirstResponder];
}



@end
